package book;

public class YieldTest {

	static class MyThread extends Thread{
		
		public void run(){
			
			long start = System.currentTimeMillis();
			int count = 0;
			for(int i = 0; i < 500000000; i++){
				
//				yield(); //加上这句会引起cpu线程切换消耗
				count += i;
			}
			long end = System.currentTimeMillis();
			System.out.println("共用时：" + ((end - start) / 1000.0));
		}
	}
	
	public static void main(String[] args) {
		
		MyThread t = new MyThread();
		t.start();
	}
}
